<?php

	ob_start();
	session_start();



	
	include_once("functions.inc.php");
	$functions = new functions();
	$stime = $functions->getmicrotime();


	include_once("config.inc.php");
	$config = new config();

	//

	include_once("libs/mi.adodb.php");
	$db = dbconn($config->db_host, $config->db_username, $config->db_password, $config->db_database, $config->db_type);
//	$db->debug=1;

	//自动导向偏好设置
	
	$general=$db->GetOne( "select shopid from {$config->db_prefix}general where admin_name = ".$db->qstr($_SESSION['ADMIN_USER']));

	if($general===false&&$_GET['s']!='general.php'){
		header("location:{$config->site_admin}m=inventory&s=general.php");
	}else{
		$user_shop=$general;
	}

	include_once("libs/mi.smarty.php");
	$smarty = new MySmarty();
	$smarty->setTemplate(MODULE_PATH.$config->dir_template);
	
	$smarty->setCache(WEBROOT."/templates_c");
	$smarty->setPlugin(MODULE_PATH."plugins");
	
	
	
	if ($user_shop&&!isset($_GET['shopid'])){
		$_GET['shopid']= $user_shop;
	}elseif ($user_shop&&$_GET['shopid']!=$user_shop){
		msg("noright.php");
	}


	include_once("template.inc.php");
	$segment = array();
	$template = new template();
	$template->content = preg_replace("/\<\?PHP(.*)exit;(.*)\?\>\r\n/i", "", $template->content);	
	echo $template->content;
		

//	echo "<p align='center'>System Execute ". round(($functions->getmicrotime()-$stime), 4). " Seconds.</p>";
	ob_end_flush();
?>